/*
 * StyledDocument.java  0.4.0 / Oct 25, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
package com.cute4j.swing.text;

/**
 * Styled Document.
 *
 * @cute4j.native
 *    generate="header"
 *
 * @author Slobodan Vrkacevic
 * @version 0.4.0
 */
public class StyledDocument extends TextDocument {

// Private Fields. -------------------------------------------------------------

  private boolean wrapText;

// Public Constructors. --------------------------------------------------------

  /**
   * Constructs new PlainDocument object.
   */
  public StyledDocument() {
    super();
  }

  /**
   * Constructs new PlainDocument object.
   *
   * @param text the text
   */
  public StyledDocument(String text) {
    super(text);
  }

// Public Methods. -------------------------------------------------------------

  /**
   * Returns <tt>true</tt> if the document is wrapping text.
   *
   * @return <tt>true</tt> if the document is wrapping text
   */
  public boolean isWrapText() {
    return wrapText;
  }

  /**
   * Sets wrap text status.
   *
   * @param wrapText if <tt>true</tt> the text area will wrap text
   */
  public void setWrapText(boolean wrapText) {
    boolean oldWrapText = this.wrapText;
    if (oldWrapText != wrapText) {
      disposedCheck();
      _setWordWrap(_delegate, wrapText);
      this.wrapText = wrapText;
      // TODO: finish
      //firePropertyChange(PROPERTY_WRAP_TEXT, oldWrapText, wrapText);
    }
  }

// Package-Private Native Methods. ---------------------------------------------

  native long _create();

  native void _setWordWrap(long delegate, boolean wrapText);

}
